import { request } from './request'

// 创建订单
export function creatOrder(params) {
  return request({
    url: '/api/orders',
    method: 'post',
    params
  })
}

// 获取订单预览
export function getOrderPreview() {
  return request({
    url: `/api/orders/preview`
  })
}

// 支付订单
export function payOrder(order, params) {
  return request({
    url: `/api/orders/${order}/pay`,
    params
  })
}

// 订单的状态
export function payOrderStatus(order) {
  return request({
    url: `/api/orders/${order}/status`
  })
}

// 获取订单列表{page:1,status:2,include:'goods,user,orderDetails'}
export function getorderList(params) {
  return request({
    url: `/api/orders`,
    params
  })
}

// 订单详情
export function getorderDetail(order) {
  return request({
    url: `/api/orders/${order}`,
    params: {
      include: 'user,orderDetails.goods'
    }
  })
}

// 确认订单
export function orderConfirm(order) {
  return request({
    url: `/api/orders/${order}/confirm`,
    method: 'patch'
  })
}

// 获取物流信息
export function orderExpress(order) {
  return request({
    url: `/api/orders/${order}/express`
  })
}
